<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>点名啦</title>
    <style>
        .footer {
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            background-color: #2f2f2f;
            color: rgb(255, 255, 255);
            text-align: center;
            padding: px 0;
            z-index: 1000;
            font-weight: bold;
            /* 确保它始终位于其他内容之上 */
        }

        .footer a {
            color: #fff;
            text-decoration: none;
            font-weight: bold;
        }

        .footer a:hover {
            text-decoration: underline;
        }
    </style>
    <style>
        body {
            margin: 0;
            padding: 0;
            font-family: 'Arial', sans-serif;
            /*background: linear-gradient(135deg, #d7dbe1, #30c4a1);*/
            background: linear-gradient(to right, #eea2a2 0%, #bbc1bf 19%, #57c6e1 42%, #b49fda 79%, #7ac5d8 100%);
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            color: white;
            overflow: hidden;
        }

        .container {
            text-align: center;
            background: rgba(255, 255, 255, 0.1);
            border-radius: 20px;
            padding: 50px;
            box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.5);
            max-width: 100%;
        }

        h1 {
            font-size: 80px;
            margin-bottom: 20px;
            text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
        }

        .name-display {
            font-size: 180px;
            font-weight: bold;
            margin: 20px 0;
            animation: flash 0.8s infinite;
        }

        @keyframes flash {

            0%,
            100% {
                opacity: 1;
            }

            50% {
                opacity: 0.3;
            }
        }

        .btn {
            background: rgba(255, 255, 255, 0.2);
            border: none;
            padding: 10px 20px;
            font-size: 18px;
            margin: 10px;
            border-radius: 5px;
            cursor: pointer;
            color: white;
            transition: background 0.3s ease;
        }

        .btn:hover {
            /*background: rgba(255, 255, 255, 0.3);*/
            background: rgb(207, 146, 232);
        }
    </style>
    <style>
        /* 设置按钮样式 */
        .settings-btn {
            position: fixed;
            top: 20px;
            right: 20px;
            background-color: #020202;
            color: white;
            border: none;
            padding: 10px 20px;
            font-size: 16px;
            font-weight: bold;
            border-radius: 5px;
            cursor: pointer;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            transition: background-color 0.3s ease;
        }

        .settings-btn:hover {
            background-color: #cf92e8;
        }

        /* 模态窗口的背景 */
        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: rgb(48, 196, 161);
            justify-content: center;
            align-items: center;
        }

        /* 模态窗口内容 */
        .modal-content {
            background-color: #fff;
            padding: 30px;
            border-radius: 10px;
            width: 90%;
            max-width: 400px;
            box-shadow: 0 10px 30px rgb(255, 255, 255);
            text-align: center;
        }

        /* 关闭按钮 */
        .close {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
            margin-right: -10px;
        }

        .close:hover,
        .close:focus {
            color: #333;
            cursor: pointer;
        }

        /* 文本框 */
        #nameInput {
            width: 80%;
            padding: 10px;
            background-color: #373737;
            margin-top: 5px;
            font-size: 16px;
            color: #ffffff;
            /* 字体颜色改为白色 */
            border: 1px solid #ffffff;
            border-radius: 10px;
            resize: none;
            font-weight: bold;
            /* 加粗字体 */
            box-shadow: inset 0 5px 3px rgb(2, 2, 2);
        }

        /* 保存按钮 */
        .save-btn {
            background-color: #ffffff;
            color: #020202;
            border: none;
            padding: 10px 20px;
            font-size: 16px;
            margin-top: 15px;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        .save-btn:hover {
            background-color: #468cee;
        }

        /* 让整个页面的字体更清晰 */
        body {
            font-family: 'Arial', sans-serif;
            font-size: 16px;
        }
    </style>

    <style>
        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgba(0, 0, 0, 0.1);
            justify-content: center;
            align-items: center;
        }

        .modal-content {
            background-color: #020202;
            margin: auto;
            padding: 20px;
            border: 1px solid #888;
            width: 80%;
            max-width: 400px;
            border-radius: 10px;
        }

        .close {
            color: #aaa;
            float: right;
            font-size: 28px;
            font-weight: bold;
        }

        .close:hover,
        .close:focus {
            color: black;
            text-decoration: none;
            cursor: pointer;
        }
    </style>

</head>

<body>
<div style="z-index:-1;position:absolute;">
    <canvas id="cas"></canvas>
</div>
<div class="container">
    <h1>Are You Ready</h1>
    <div class="name-display" id="nameDisplay">Start</div>
    <button class="btn" id="startBtn">开始（它可以随机停止）</button>
    <button class="btn" id="pauseBtn" disabled>暂停（它可以立即暂停）</button>
</div>


<button id="settingsBtn" class="settings-btn">设置(Setting)</button>


<div id="settingsModal" class="modal">
    <div class="modal-content">
        <span class="close">&times;</span>
        <h2>输入名单(Names In)</h2>
        <label for="nameInput"></label><textarea id="nameInput" rows="10" cols="30"
                                                 placeholder="输入名单，每行一个名字"></textarea>
        <br>
        <button id="saveBtn" class="save-btn">保存(Save)</button>
    </div>
</div>


<script>

    const nameDisplay = document.getElementById('nameDisplay');
    const startBtn = document.getElementById('startBtn');
    const pauseBtn = document.getElementById('pauseBtn');

    let interval;
    let usedNames = [];

    // 获取随机名称
    // 获取随机名称
    function getRandomName() {
        if (usedNames.length === names.length) {
            usedNames = [];  // 重置已用名字列表
        }
        let availableNames = names.filter(name => !usedNames.includes(name));

        if (availableNames.length === 0) {
            // 如果所有名字都已使用过，则重置并返回
            availableNames = names;
            usedNames = [];
        }

        let randomName = availableNames[Math.floor(Math.random() * availableNames.length)];
        usedNames.push(randomName);
        return randomName;
    }


    // 开始随机点名
    function startRandom() {
        startBtn.disabled = true;
        pauseBtn.disabled = false;

        interval = setInterval(() => {
            nameDisplay.textContent = getRandomName();
        }, 65); // 数字为每个显现时间

        // 随机生成一个暂停时间
        let randomPauseTime = Math.floor(Math.random() * 1000) + 1500; // 1-2.5秒内随机暂停
        setTimeout(() => {
            pauseRandom();
        }, randomPauseTime);
    }

    // 暂停点名
    function pauseRandom() {
        clearInterval(interval);
        startBtn.disabled = false;
        pauseBtn.disabled = true;
    }

    startBtn.addEventListener('click', startRandom);
    pauseBtn.addEventListener('click', pauseRandom);
</script>
<div class="footer">
<!--    <p>🌻🌸To The Most Beautiful Teacher Zhang🌸🌻</p>-->
<!--    <p>Study Hard And Make Progress Every Day</p>-->
    <p>🌻🌸To My Love, Teacher Zhang🌸🌻</p>
    <p style="font-size: 12px"><a href="https://gitee.com/a-bag-of-rice-should-resist-ji/roll-call-system"
                                  style="color: azure"
                                  target="_blank">出自：gitee Author：Mr.Fang</a></p>
</div>
<script type="text/javascript" src="nameread.js"></script>
<script src="sakura.js"></script>
<script src="particle.js"></script>
</body>
</html>